﻿/**
* Proyecto: Cognitum
* Global IT Services 2008
* @author
*/

Cognitum.Polizas.Endoso.DescartarEndosoBForm = Ext.extend(Ext.Window, {
    initComponent: function() {
        endoso = null;

        Ext.apply(this, {
            id: 'winDescartarEndosoB',
            modal: true,
            title: 'Descartar Endoso',
            width: 400,
            frame: true,
            height: 230,
            items: {
                xtype: 'form',
                id: 'frmDescartar',
                name: 'frmDescartar',
                anchor: '100% 100%',
                labelWidth: 180,
                frame: true,
                items: [{
                    xtype: 'textfield',
                    name: 'Folio',
                    id: 'txtFolio',
                    anchor: '90%',
                    fieldLabel: 'No. Endoso',
                    allowBlank: false
                }, {
                    xtype: 'radiogroup',
                    id: 'rdgModifica',
                    fieldLabel: '¿Desea modificar la caratula?',
                    anchor: '95%',
                    scope: this,
                    columns: 1,                    
                    items: [
						{ boxLabel: 'Si', name: 'optModificaCaratula', inputValue: 1, checked: true },
						{ boxLabel: 'No', name: 'optModificaCaratula', inputValue: 0 }
					]
                }],
                buttons: [{
                    text: 'Descartar',
                    handler: function() {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug('[EndosoB.DescartarForm.descartar] - Folio: ' + this.findById('txtFolio').getValue());
                            LOG.debug('[EndosoB.DescartarForm.descartar] - Genera Recibos: ' + this.findById('rdgModifica').items.first().getValue());                            
                        }
                        var folio = this.findById('txtFolio').getValue();
                        var modificaCaratula = this.findById('rdgModifica').items.first().getValue();
                        
                        if (folio != '') {                            
                            this.fireEvent('descartarB', folio, modificaCaratula);
                            this.close();
                        } else {
                            Ext.MessageBox.alert('Folio Incorrecto', 'Debe ingresar un Folio.');
                        }
                    },
                    scope: this
                }, {
                    text: 'Cancelar',
                    handler: function() {
                        this.close();
                    },
                    scope: this
                    }]
                }
            });
            this.addEvents({ 'descartarB': true });
            Cognitum.Polizas.Endoso.DescartarEndosoBForm.superclass.initComponent.apply(this, arguments);
            this.doLayout(true);
        }        

    });
